export const normalizeDate = (date: any) => {
    let time: any = new Date(date)
    let y: any = time.getFullYear()
    let M: any = time.getMonth() + 1
    let d: any = time.getDate()
    let h: any = time.getHours()
    let m: any = time.getMinutes()
    let s: any = time.getSeconds()
    let res: any = [y, M, d, h, m, s].map(v => v.toString().padStart(2, 0))
    return res.slice(0, 3).join('/') + " " + res.slice(3).join(':')
}
//处理时间格式函数【年/月/日】
export const normalizeYmd = (date: any) => {
    let time: any = new Date(date)
    let y: any = time.getFullYear()
    let M: any = time.getMonth() + 1
    let d: any = time.getDate()
    let res: any = [y, M, d].map(v => v.toString().padStart(2, 0))
    return res.slice(0, 3).join('/')
}
//处理时间格式函数【时：分：秒】
export const normalizeHms = (date: any) => {
    let time: any = new Date(date)
    let h: any = time.getHours()
    let m: any = time.getMinutes()
    let s: any = time.getSeconds()
    let res: any = [h, m, s].map(v => v.toString().padStart(2, 0))
    return res.join(':')
}
//数字 处理为每3位逗号隔开
export const dealNumber = (num: any) => {
    if (num != 0 && num) {
        num = num + ""
        let decimalsStr: any = "";
        let splitList: any = num.split(".");
        //先处理小数部分
        if (splitList[1]) {
            //如果有2位小数则保留2位，只有1位则添0
            decimalsStr = decimalsStr.substring(0, 2).length == 2 ? decimalsStr.substring(0, 2) : decimalsStr.substring(0, 2) + "0";
        }
        //整数部分
        //将整数部分拆解为单个数字的数组倒序，然后拼装为新的数组，每3位数字进行一次匹配
        let intStrList: any = splitList[0].split("").reverse().join('').match(/(\d{1,3})/g);
        //将匹配后的数组用，拼接，再拆解为单个数字的数组，反转为原先数组形式，拼接为完整数字
        let intStr: any = intStrList.join(',').split('').reverse().join('');
        return intStr + decimalsStr;
    }
    return num
}